package com.bnlr.lrparking.appui.carport.recommend;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.bnlr.lrparking.R;
import com.bnlr.lrparking.view.LabelLinearLayout;

import java.util.List;

/**
 * @author : tian
 * time   : 2018/03/31
 * desc   : 推荐车位适配器
 */

public class RecommendStallAdapter extends BaseQuickAdapter<RecommendStallBean.ModelBean.ListBean,BaseViewHolder>{
    public RecommendStallAdapter(@Nullable List<RecommendStallBean.ModelBean.ListBean> data) {
        super(R.layout.item_recommend_stall_layout,data);
    }
    @Override
    protected void convert(BaseViewHolder helper, RecommendStallBean.ModelBean.ListBean item) {
        helper.setIsRecyclable(false);
        Glide.with(mContext).load(item.getPhotoUrl())
                .placeholder(R.mipmap.tab2_defaultgraph)
                .error(R.mipmap.tab2_defaultgraph)
                .into((ImageView) helper.getView(R.id.iv_stall_rent_out));

        helper.setText(R.id.tv_stall_rent_out_title,item.getTitle());

        helper.setText(R.id.tv_stall_rent_out_price,item.getPrice()+item.getPriceUnit());
        helper.setText(R.id.tv_stall_rent_out_status,item.getStatus()+" ");
        // 车位归属
        if (item.getSpaceOwerType() == 0) {
            helper.setText(R.id.tv_stall_rent_out_who,"个人");
            helper.setText(R.id.tv_stall_rent_out_size,"平台编号："+item.getCommonNumber());
        } else {
            helper.setText(R.id.tv_stall_rent_out_who,"开发商");
            helper.setText(R.id.tv_stall_rent_out_size,"车位编号："+item.getNumber());
        }
        LabelLinearLayout lll = helper.getView(R.id.ll_stall_discount);
        if (item.getDiscount() != null && item.getDiscount().size() > 0) {
            lll.removeAllViews();
            helper.setVisible(R.id.ll_stall_address,false);
            lll.setVisibility(View.VISIBLE);
            lll.setLabels(item.getDiscount());
        } else {
            helper.setVisible(R.id.ll_stall_address,true);
            lll.setVisibility(View.GONE);
            helper.setText(R.id.tv_stall_rent_out_address,item.getAddress());
        }

    }
}
